<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Templatebeian extends Model
{
    protected $table = 'template_beian';
    protected $primaryKey = 'id';

    public static function templateBeianLists($users_id)
    {
        return self::where("users_id",$users_id)->where("disable",1)->get();
    }

    public static function templateBeianListName($users_id)
    {
        return self::select("id","remark","legal_person","province")->where("users_id",$users_id)->where("disable",1)->get();
    }

    public static function templateBeianCount($users_id)
    {
        return self::where("users_id",$users_id)->where("disable",1)->count("id");
    }

    public static function templateBeianByName($users_id,$certificate_number,$principal_info)
    {
        return self::where("users_id",$users_id)->where("principal_info",$principal_info)->where("certificate_number",$certificate_number)->where("disable",1)->first();
    }

    public static function templateBeianDetial($id)
    {
        return self::where("id",$id)->first();
    }

    public static function templateBeianUpdate($id,$beian_info,$remark,$province,$principal_info,$legal_person,$certificate_number)
    {
        return self::where("id",$id)->update(["beian_info"=>$beian_info,"remark"=>$remark,"province"=>$province,"principal_info"=>$principal_info,"legal_person"=>$legal_person,"certificate_number"=>$certificate_number]);
    }

    public static function templateBeianInsert($users_id,$beian_info,$remark,$province,$principal_info,$legal_person,$certificate_number)
    {
        return self::insert(["users_id"=>$users_id,"remark"=>$remark,"beian_info"=>$beian_info,"province"=>$province,"principal_info"=>$principal_info,"legal_person"=>$legal_person,"certificate_number"=>$certificate_number,"created_at"=>time()]);
    }

}
